
/*验证码刷新的js*/
$(function () {
	
		$("a").click(function(){
			var d = new Date();
			$("#img").get(0).src ="code.jsp;time="+d.getTime();
		});
		
		$("#image").click(function () {
			$("#imageselect").css("display","block");
		});
		
		$("#closeselecticon").click(function () {
			$("#imageselect").css("display","none");
		});
		
		
		
		form = $('#updateform');

		form.bootstrapValidator({
			excluded: 'disabled',
		    message: '输入值不合法',
		    feedbackIcons: {
		        valid: 'glyphicon glyphicon-ok',
		        invalid: 'glyphicon glyphicon-remove',
		        validating: 'glyphicon glyphicon-refresh'
		    },
		    live: 'enabled',
		    fields: {
		        loginname: {
		            message: '用户名不合法',
		            validators: {
		                notEmpty: {
		                    message: '用户名不能为空'
		                },
		                stringLength: {
		                    min: 3,
		                    max: 30,
		                    message: '请输入3到30个字符'
		                },
		                regexp: {
		                    regexp: /^[a-zA-Z0-9_\. \u4e00-\u9fa5 ]+$/,
		                    message: '用户名只能由字母、数字、点、下划线和汉字组成 '
		                }
		            }
		        }
		        ,
		        email: {
		            validators: {
		                notEmpty: {
		                    message: 'email不能为空'
		                },
		                emailAddress: {
		                    message: '请输入正确的邮件地址如：123@qq.com'
		                }
		            }
		        }, 
		        
		        password: {
		            validators: {
		            	stringLength: {
		                    min: 3,
		                    max: 10,
		                    message: '请输入3到10个字符'
		                },
		                notEmpty: {
		                    message: '密码不能为空'
		                }
		            }
		        }, 
		        
		        okpassword: {
		            validators: {
		                notEmpty: {
		                    message: '确认密码不能为空'
		                }, 
		                identical: {
		                    field: 'password',
		                    message: '密码不一致！'
		                 },
		                stringLength: {
		                    min: 3,
		                    max: 10,
		                    message: '请输入3到10个字符'
		                }
		            }
		        },
		       incode: {
		            validators: {
		                notEmpty: {
		                    message: '验证码不能为空'
		                }, 
		                stringLength: {
		                    min: 4,
		                    max: 4,
		                    message: '请输入4个字符'
		                }
		            }
		        }
		    }
		});
		
	
		
		
		

		$("#submitBtn").click(function () {
		//进行表单验证
			 
		var bv = form.data('bootstrapValidator');

		bv.validate();

		if (bv.isValid()) {
		    $.post("UserServlet",form.serialize(),function(data){
		    	if(data=="1"){
		    		  $("#returnMessage").hide().html('<label class="label label-danger">注册成功!</label>').show(300);
		    	}
		    	if(data=="2"){
		    		$("#returnMessage").hide().html('<label class="label label-danger">用户已经存在!</label>').show(300);
		    	}
		    	if(data=="3"){
		    		$("#returnMessage").hide().html('<label class="label label-danger">验证码输入错误!</label>').show(300);
		    	}
		    },"text");
		   
		}

		});
		
	   

});

//选择头像
function choose(src) {
	$("#wenzi").css("display","none");
	$("#usericon").attr("src",src);
	$("#imageselect").css("display","none");
	$("#iconurl").val(src);
}


	

 